﻿// Copyright 2010 Maxime Serrano <lastchronicler@gmail.com>
// Copyright 2009, 2010 Matvei Stefarov <me@matvei.org>
using System;

namespace ForgeCraft
{
    public class CmdSummon : Command
    {
        public override string name { get { return "summon"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "op"; } }
        public override bool consoleUsable { get { return false; } }
        public override Permission defaultRank { get { return Permission.Guest; } }
        public CmdSummon() { }

        public override void Use(Player p, string message)
        {
            string name = message;
            if (name == null)
            {
                p.Message(Color.Announcement + "You must specify a player name!");
                return;
            }
            Player target = Server.FindPlayer(name);
            if (target == null)
            {
                p.NoPlayerMessage(name);
            }
            else
            {
                Position pos = p.pos;
                pos.y += 2;
                target.Send(PacketWriter.MakePositionAndLook(pos));
            }
        }
        public override void Help(Player p)
        {
            p.Message(Color.Aqua + "/summon " + Color.Help + "- Teleports a player to you.");           
        }
    }
}